home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 16 / printer.fth < prev    next >
Text File  |  1985-11-19  |  2KB  |  73 lines

  1. \ Printer control.
  2. \ This hasn't been tested very well because I don't have a printer.
  3. \
  4. \ Defines a vocabulary called  printer  which contains:
  5. \
  6. \ (print)  ( char -- )    Output a character to the printer
  7. \ print            Subsequent output goes to both printer and screen
  8. \            until the next Forth prompt
  9. \ print-file filename    Print the named file
  10. \
  11. \ Setting the printer parameters:   Execute the appropriate commands from
  12. \ this list, then execute  set-printer   (or use the desk accessory)
  13. \
  14. \ dot-matrix   or   daisy-wheel
  15. \ color        or   monochrome
  16. \ atari        or   epson
  17. \ draft        or   final
  18. \ parallel     or   serial
  19. \ form-feed    or   single-sheet
  20.  
  21. decimal
  22. only forth also definitions
  23. vocabulary printer  printer definitions
  24.  
  25. only forth also printer also definitions
  26.  
  27. 33 xbios: setprt  { w.config -- w.old-config }
  28.  
  29. wvariable printer-config  0 printer-config w!
  30.  
  31. : set-printer ( -- )  printer-config w@ setprt drop ;
  32.  
  33. : pset ( mask -- )      printer-config w@ or printer-config w! ;
  34. : pclr ( mask -- ) not  printer-config w@ or printer-config w! ;
  35.  
  36. hex
  37. : dot-matrix  1 pclr ;   : daisy-wheel   1 pset ;
  38. : color       2 pclr ;   : monochrome    2 pset ;
  39. : atari       4 pclr ;   : epson         4 pset ;
  40. : draft       8 pclr ;   : final         8 pset ;
  41. : parallel   10 pclr ;   : serial       10 pset ;
  42. : form-feed  20 pclr ;   : single-sheet 20 pset ;
  43. decimal
  44.  
  45. 5 bdos: c_prnout  { w.char -- }
  46. alias (print) c_prnout
  47.  
  48. : premit ( char -- )  dup (print) sys-emit  ;
  49.  
  50. only forth printer also forth hidden also forth definitions
  51. : print ( -- )        \ turn printer on
  52.    ['] status >data token@  old-status token!
  53.    ['] console-output  is status
  54.    ['] premit          is (emit
  55. ;
  56. : (print-file  ( -- )
  57.    begin ifd @ fgetc  dup 0>=
  58.    while  (print)
  59.    repeat
  60.    drop  ifd @ close
  61. ;
  62. : print-file  \ filename  ( -- )
  63.    reading   (print-file
  64. ;
  65.  
  66. only forth also definitions
  67.   jmp
  68.         d1 a0 )  lmove
  69.      then
  70.      2 a0 addq
  71.   repeat
  72. c;
  73. \ Change all the next routines in